console.show()
//需查找的关键字，或控件
let keyName = className("android.widget.EditText")//组件
//let keyName = "签到"//关键字
let keyKind = 1 //关键字类型：0：文本；1：控件

while(keyKind == 0){
  console.log("当前应用名:  " + app.getAppName(currentPackage())+ "\n"
    +"当前活动:  " + currentActivity()+ "\n"
    +"未识别到<"+keyName+">，继续等待……");
  if(text(keyName).exists()){
    console.log("关键字中心位置："+text(keyName).findOne().bounds().centerX()+","+text(keyName).findOne().bounds().centerY())
    console.log("关键字对应控件是否可点击："+text(keyName).findOne().clickable())
    console.log("关键字对应上级控件是否可点击："+text(keyName).findOne().parent().clickable())
    console.log("脚本结束")
    exit();
  }
  sleep(2000);
}
while(keyKind == 1){
  console.log("当前应用名:  " + app.getAppName(currentPackage())+ "\n"
  +"当前活动:  " + currentActivity()+ "\n"
  +"未识别到<控件>，继续等待……");
  if(keyName.exists()){
    console.log("关键控件中心位置："+keyName.findOne().bounds().centerX()+","+keyName.findOne().bounds().centerY())
    console.log("关键控件对应控件是否可点击："+keyName.findOne().clickable())
    console.log("关键控件对应上级控件是否可点击："+keyName.findOne().parent().clickable())
    console.log("脚本结束")
    exit();
  }
  sleep(2000);
}

